package com.sicau.socialpracticesystem.common.myenum;

/**
 * @author sxt
 * @version : 1.0.0
 */
public enum UserTypeEnum {

    EMPTY("游客用户", "ROLE_VISITOR", -1),
    USER("普通用户", "ROLE_USER", 0),
    ADMIN("管理员", "ROLE_ADMIN", 1);

    UserTypeEnum(String type, String userIns, Integer typeCode) {
        this.type = type;
        this.userIns = userIns;
        this.typeCode = typeCode;
    }

    /**
     * 用户类型
     */
    private final String type;

    /**
     * 用户类型标识
     */
    private final String userIns;

    /**
     * 用户类型码
     */
    private final Integer typeCode;

    public String getType() {
        return type;
    }

    public Integer getTypeCode() {
        return typeCode;
    }

    public String getUserDes() {
        return userIns;
    }

    public static String getTypeByCode(Integer typeCode) {
        UserTypeEnum[] values = values();
        for (UserTypeEnum userTypeEnum : values) {
            if (userTypeEnum.getTypeCode().equals(typeCode)){
                return userTypeEnum.getType();
            }
        }
        return null;
    }
}
